/*
 * =====================================================================================
 *
 *       Filename:  CLcd.h
 *
 *    Description:  this is LCD operation header file
 *
 *        Version:  1.0
 *        Created:  2011年11月16日 15时58分06秒
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  Michael Lee
 *        Company:  KGE
 *
 * =====================================================================================
 */
#ifndef CLCD_H
#define CLCD_H

#include "publicFun.h"

enum ekeyNum
{
	KEYUP=0,
	KEYDOWN,
	KEYLEFT,
	KEYRIGHT,
	KEYENTER,
	KEYESC
};


class CLcd
{
public:
	CLcd();
	~CLcd();
	int ReadKey(unsigned char *keyc);
	int Init();
	void Clear(unsigned  rowIndex);
	void Fresh();
	void DrawPixel(int x, int y, unsigned colorIndex);
	void SetBlackLight(int on); //on =1 ?a
	void SetContrast(unsigned char con);
	bool OpenHzk();
	void CloseHzk();
	bool OpenYwk();
	void CloseYwk();
	bool OpenBtn();
	void CloseBtn();
	void PutString(int x, int y, char *s, unsigned colorIndex);
	void CleanPixel();
	void CloseLcd();
	void ReverseLine(unsigned char rowIndex , unsigned char Flag);
	void ReverseHZ(unsigned char x0, unsigned char rowIndex, unsigned char HZcounts);
	void ReverseBit(unsigned char bitIndex , unsigned char rowIndex);
	
private:
	int GetChIndex__(char *s);
	void PutChar__(int x, int y, int colorIndex);
	void PutCharW__(int x, int y, int colorIndex);
	void GetChChar32__(int j, char *mold);
	void GetEnChar32__(int j, char *mold);
	void Line__(int x1, int y1, int x2, int y2, unsigned colorIndex);
	void Rect__(int x1, int y1, int x2, int y2, unsigned colorIndex);
	void Box__(int x1, int y1, int x2, int y2, unsigned colorIndex);
	
    char*   fbptr;
	char	mold[32];
    int	    fontw;
    int	    fonth;
    int	    font_half_width;
    int		xres, yres;
    int		fbpp, lineLen;
    int     fbFd;
    int     kbdFd;
    int     handle_hzk;
    int     handle_ywk;
};
#endif
